package com.gohome.gohomechat.presenter;

import com.gohome.gohomechat.model.SelectorContantModel;
import com.gohome.gohomechat.model.entify.Friend;
import com.gohome.gohomechat.model.modellistener.SelectorContantModelListener;
import com.gohome.gohomechat.presenter.callback.SelectorContantCallBack;
import com.gohome.gohomechat.presenter.presenterlistener.SelectorContantPresenterInterface;
import com.gohome.gohomechat.ui.viewlistener.SelectorContantViewInterface;

import java.util.List;

/**
 * Created by dllo on 16/3/11.
 */
public class SelectorContantPresenter extends BasePresenter<SelectorContantViewInterface> implements SelectorContantPresenterInterface {
    private SelectorContantViewInterface selectorContantViewInterface;
    private SelectorContantModelListener selectorContantModelListener;

    public SelectorContantPresenter(SelectorContantViewInterface createGroupViewInterface) {
        this.selectorContantViewInterface = createGroupViewInterface;
        selectorContantModelListener=new SelectorContantModel();
    }

    @Override
    public void createGroup(String groupName, String dec, boolean isPublic, boolean isInvitation,String[] members) {
        selectorContantViewInterface.showDialog();
        selectorContantModelListener.createGroup(groupName, dec, isPublic, isInvitation,members ,new SelectorContantCallBack() {
            @Override
            public void success() {
                selectorContantViewInterface.dismissDialog();
                selectorContantViewInterface.saveSuccess();
            }

            @Override
            public void failed() {
                selectorContantViewInterface.dismissDialog();
                selectorContantViewInterface.saveFailed();
            }

            @Override
            public void requestData(List<Friend> datas) {

            }
        });
    }

    @Override
    public void requestData() {
        selectorContantViewInterface.showDialog();
        selectorContantModelListener.requestData(new SelectorContantCallBack() {
            @Override
            public void success() {

            }

            @Override
            public void failed() {
                selectorContantViewInterface.dismissDialog();
            }

            @Override
            public void requestData(List<Friend> datas) {
                selectorContantViewInterface.requestSuccess(datas);
                selectorContantViewInterface.dismissDialog();
            }
        });
    }
}
